﻿namespace HuwmanCode

open System

[<AutoOpen>]
module IntPtrExtension =
    type System.IntPtr with
        /// <summary>
        /// Converts an IntPtr value to an IntPtr option. 
        /// IntPtr.Zero = None
        /// </summary>
        member x.ToOption() =
            Option.create(x <> IntPtr.Zero, x)

        /// <summary>
        /// Converts an IntPtr value to an IntPtr option. 
        /// IntPtr.Zero = None
        /// </summary>
        member x.ToOption(value) =
            Option.create(x <> IntPtr.Zero, (x, value))
        